Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Improve diagnostic generation/handling, enable diagnostics with setting - #289

Closed
Jake Bailey (jakebailey) wants to merge 4 commits into
microsoft:masterfrom
jakebailey:diagnostics
Closed

Jake Bailey (jakebailey) wants to merge 4 commits into
microsoft:masterfrom
jakebailey:diagnostics

Conversation

@jakebailey

@jakebailey Jake Bailey (jakebailey) commented Oct 19, 2018 •

Copy link
Copy Markdown
Member

Fixes #242.

This does the following:

  • Fixes diagnostics when settings are changed at runtime. Previously, only the mapping from code to severity was updated, not the actual listing, so diagnostics were never re-run even when settings were changed.
  • Moves all severity decision and diagnostic filtering upward into the LS. This means all generated diagnostics will be published as-is, and any future additions (i.e. import code actions) can be generated when new diagnostics are published.
  • Adds a setting called python.analysis.diagnostics which is true when diagnostics should be published altogether (and also triggers an update when changed). The default behavior remains the same; users will not see any diagnostics until VSC adds the setting to its package.json. Devs (us) can set this in the JSON just like we set downloadLanguageServer even though it's undocumented. Default will be enabled, as per PR comments.

Looking for feedback on:

  • The naming of python.analysis.diagnostics.
  • Whether or not I should be removing EnableDiagnostics now that the toggle is focused on deciding whether or not to publish diagnostics, not whether or not to collect them.

@jakebailey

Copy link
Copy Markdown
Member Author

Of course, the added setting needs to make it into VSC before their release, otherwise #242 isn't fixed in principle.

var reanalyze = true;
if (@params.settings != null) {
if (@params.settings is ServerSettings settings) {
Analyzer.EnableDiagnostics = settings.analysis.diagnostics;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setting needs to be added to the package.json in the extension defaulting to true

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I've done that locally for now (until I PR it), since I wasn't 100% sure on the naming.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don Jayamanne (@DonJayamanne) can suggest name of the setting

@jakebailey

Copy link
Copy Markdown
Member Author

I'm going to close this in favor of #298. Adding this setting complicates things in terms of how to deal with parsing diagnostics that I'm not confident this change can properly handle.

Jake Bailey (jakebailey) added a commit that referenced this pull request Oct 23, 2018
Fixes #242.

#289 causes a few issues to do with parser-generated diagnostics, and there are more diagnostics I wasn't aware of coming from ErrorSink. This is a simplified PR that does the minimum to enable diagnostics (ignoring "Unspecified" at publish time) and fixes the setting change bug.

We'll have to revisit where diagnostics should be stored to access via code actions in a different PR. There are only two diagnostics that actually come out of the server which can be disabled with `python.analysis.disabled` for now.

I'll close #289 in favor of this one.
@jakebailey
Jake Bailey (jakebailey) deleted the diagnostics branch February 14, 2019 20:12
Jake Bailey (jakebailey) added a commit to jakebailey/python-language-server that referenced this pull request Nov 1, 2019
)

Fixes microsoft#242.

microsoft#289 causes a few issues to do with parser-generated diagnostics, and there are more diagnostics I wasn't aware of coming from ErrorSink. This is a simplified PR that does the minimum to enable diagnostics (ignoring "Unspecified" at publish time) and fixes the setting change bug.

We'll have to revisit where diagnostics should be stored to access via code actions in a different PR. There are only two diagnostics that actually come out of the server which can be disabled with `python.analysis.disabled` for now.

I'll close microsoft#289 in favor of this one.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants